package com.yun.many.auth.controller;

import com.yun.many.auth.model.group.ValidGroup;
import com.yun.many.auth.model.req.RoleEditReq;
import com.yun.many.auth.service.IRoleService;
import com.yun.many.spec.vo.HttpResult;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("role")
@RequiredArgsConstructor
public class RoleController extends BaseController {
    private final IRoleService roleService;

    @PostMapping("add")
    public HttpResult<Boolean> add(@Validated({ValidGroup.Add.class}) RoleEditReq req, BindingResult result) {
        validate(result);
        Boolean addResult = roleService.add(req);
        return HttpResult.success(addResult);
    }
}
